package delta;

import java.util.ArrayList;

public class Field {
	protected ArrayList<Field> surroundingFields;
	protected ArrayList<IFieldable> objects;
	
	

	public Field() {
		surroundingFields = new ArrayList<Field>();
		objects = new ArrayList<IFieldable>();
	}

	public ArrayList<Field> getSurroundingFields() {
		return surroundingFields;
	}

	public void connect(Field field) {
		surroundingFields.add(field);
	}

	public void update() {
		for (int i=0;i<objects.size();i++){
			objects.get(i).update();
		//for (IFieldable iFieldable : objects) {
		//	iFieldable.update();
		}
	}
	
	public String toString() {		//tesztelesi celokra
		StringBuilder str = new StringBuilder();
		for (IFieldable iFieldable : objects) {
			str.append(iFieldable);
		}
		
		return str.toString();
	}

	public synchronized void addObject(IFieldable o) {
		objects.add(o);
	}
	public synchronized void removeObject(IFieldable o) {
		objects.remove(o);
	}
	
	public ArrayList<IFieldable> getObjects() {
		return objects;
	}
	public Integer getDistance() {
		return -1;
	}
}
